//
// Created by whitby on 8/22/23.
//

#ifndef MONO_ORB_SLAM2_OPTIMIZE_H
#define MONO_ORB_SLAM2_OPTIMIZE_H

#include "BasicObject/KeyFrame.h"
#include "BasicObject/Map.h"

#include <g2o/core/block_solver.h>
#include <g2o/solvers/eigen/linear_solver_eigen.h>

namespace mono_orb_slam2 {

    class Optimize {
        typedef g2o::LinearSolverEigen<g2o::BlockSolver_6_3::PoseMatrixType> LinearSolverEigen_6_3;

    public:
        static void
        initialOptimize(const std::shared_ptr<KeyFrame> &lastKeyFrame, const std::shared_ptr<KeyFrame> &curKeyFrame);

        static int poseOptimize(const std::shared_ptr<Frame> &frame);

        static void localBundleAdjustment(const std::shared_ptr<KeyFrame> &keyFrame, Map *pointMap, bool *stopFlag = nullptr);
    };

} // mono_orb_slam2

#endif //MONO_ORB_SLAM2_OPTIMIZE_H
